<template>
    <div>
        <van-search v-model="search" placeholder="请输入搜索关键词" />
        <van-cell-group v-for="item in searchData">
            <router-link :to="'/detail/' + item.goods_id">
                <van-cell :title="item.goods_name" value="内容" />
            </router-link>
        </van-cell-group>
    </div>
</template>

<script setup>
import { ref, watch } from 'vue'
import { useRouter } from 'vue-router'
const router = new useRouter()
const searchData = ref([])
import { searchApi } from '@/api/api'
import _ from 'lodash'

const search = ref('')

watch(search, _.debounce((search) => {
    searchApi(search).then((res) => {
        console.log(res);
        searchData.value = res.data.message;
    })
}, 1000))
</script>

<style lang="scss" scoped></style>